/*     */ package com.zimbra.cs.index;
/*     */ 
/*     */ import com.google.common.base.Strings;
/*     */ import com.zimbra.cs.index.analysis.FieldTokenStream;
/*     */ import com.zimbra.cs.index.analysis.MimeTypeTokenStream;
/*     */ import com.zimbra.cs.index.analysis.RFC822AddressTokenStream;
/*     */ import org.apache.lucene.document.DateTools;
/*     */ import org.apache.lucene.document.DateTools.Resolution;
/*     */ import org.apache.lucene.document.Document;
/*     */ import org.apache.lucene.document.Field;
/*     */ import org.apache.lucene.document.Field.Index;
/*     */ import org.apache.lucene.document.Field.Store;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public final class IndexDocument
/*     */ {
/*     */   private final Document document;
/*     */   
/*     */   public IndexDocument()
/*     */   {
/*  37 */     this.document = new Document();
/*     */   }
/*     */   
/*     */   public IndexDocument(Document doc) {
/*  41 */     this.document = doc;
/*     */   }
/*     */   
/*     */   public Document toDocument() {
/*  45 */     return this.document;
/*     */   }
/*     */   
/*     */   public void addMimeType(MimeTypeTokenStream stream) {
/*  49 */     this.document.add(new Field("type", stream));
/*     */   }
/*     */   
/*     */   public void addPartName(String value) {
/*  53 */     this.document.add(new Field("l.partname", value, Field.Store.YES, Field.Index.NOT_ANALYZED));
/*     */   }
/*     */   
/*     */   public void addFilename(String value) {
/*  57 */     this.document.add(new Field("filename", value, Field.Store.YES, Field.Index.ANALYZED));
/*     */   }
/*     */   
/*     */   public void addSortSize(long value) {
/*  61 */     this.document.add(new Field("l.size", String.valueOf(value), Field.Store.YES, Field.Index.NOT_ANALYZED));
/*     */   }
/*     */   
/*     */   public void removeSortSize()
/*     */   {
/*  66 */     this.document.removeFields("l.size");
/*     */   }
/*     */   
/*     */   public void addSortAttachment(boolean value) {
/*  70 */     this.document.add(new Field("hasAttach", LuceneFields.valueForBooleanField(value), Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS));
/*     */   }
/*     */   
/*     */   public void removeSortAttachment()
/*     */   {
/*  75 */     this.document.removeFields("hasAttach");
/*     */   }
/*     */   
/*     */   public void addSortFlag(boolean value) {
/*  79 */     this.document.add(new Field("hasFlag", LuceneFields.valueForBooleanField(value), Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS));
/*     */   }
/*     */   
/*     */   public void removeSortFlag()
/*     */   {
/*  84 */     this.document.removeFields("hasFlag");
/*     */   }
/*     */   
/*     */   public void addSortPriority(int value) {
/*  88 */     this.document.add(new Field("priority", LuceneFields.valueForPriority(value), Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS));
/*     */   }
/*     */   
/*     */   public void removeSortPriority()
/*     */   {
/*  93 */     this.document.removeFields("priority");
/*     */   }
/*     */   
/*     */   public void addFrom(RFC822AddressTokenStream stream) {
/*  97 */     this.document.add(new Field("from", stream));
/*     */   }
/*     */   
/*     */   public void removeFrom() {
/* 101 */     this.document.removeFields("from");
/*     */   }
/*     */   
/*     */   public void addTo(RFC822AddressTokenStream stream) {
/* 105 */     this.document.add(new Field("to", stream));
/*     */   }
/*     */   
/*     */   public void removeTo() {
/* 109 */     this.document.removeFields("to");
/*     */   }
/*     */   
/*     */   public void addCc(RFC822AddressTokenStream stream) {
/* 113 */     this.document.add(new Field("cc", stream));
/*     */   }
/*     */   
/*     */   public void removeCc() {
/* 117 */     this.document.removeFields("cc");
/*     */   }
/*     */   
/*     */   public void addEnvFrom(RFC822AddressTokenStream stream) {
/* 121 */     this.document.add(new Field("env_from", stream));
/*     */   }
/*     */   
/*     */   public void addEnvTo(RFC822AddressTokenStream stream) {
/* 125 */     this.document.add(new Field("env_to", stream));
/*     */   }
/*     */   
/*     */   public void addMessageId(String value) {
/* 129 */     this.document.add(new Field("msg_id", value, Field.Store.NO, Field.Index.NOT_ANALYZED));
/*     */   }
/*     */   
/*     */   public void addField(FieldTokenStream stream) {
/* 133 */     this.document.add(new Field("l.field", stream));
/*     */   }
/*     */   
/*     */   public void addSortName(String value) {
/* 137 */     if (Strings.isNullOrEmpty(value)) {
/* 138 */       return;
/*     */     }
/* 140 */     this.document.add(new Field("nameSort", value.toLowerCase(), Field.Store.NO, Field.Index.NOT_ANALYZED));
/*     */   }
/*     */   
/*     */   public void removeSortName()
/*     */   {
/* 145 */     this.document.removeFields("nameSort");
/*     */   }
/*     */   
/*     */   public void addSubject(String value) {
/* 149 */     this.document.add(new Field("subject", value, Field.Store.NO, Field.Index.ANALYZED));
/*     */   }
/*     */   
/*     */   public void removeSubject() {
/* 153 */     this.document.removeFields("subject");
/*     */   }
/*     */   
/*     */   public void addSortSubject(String value) {
/* 157 */     if (Strings.isNullOrEmpty(value)) {
/* 158 */       return;
/*     */     }
/* 160 */     this.document.add(new Field("subjSort", value.toUpperCase(), Field.Store.NO, Field.Index.NOT_ANALYZED));
/*     */   }
/*     */   
/*     */   public void removeSortSubject()
/*     */   {
/* 165 */     this.document.removeFields("subjSort");
/*     */   }
/*     */   
/*     */   public void addContent(String value) {
/* 169 */     this.document.add(new Field("l.content", value, Field.Store.NO, Field.Index.ANALYZED));
/*     */   }
/*     */   
/*     */   public void addAttachments(MimeTypeTokenStream stream) {
/* 173 */     this.document.add(new Field("attachment", stream));
/*     */   }
/*     */   
/*     */   public void addMailboxBlobId(int value) {
/* 177 */     this.document.add(new Field("l.mbox_blob_id", String.valueOf(value), Field.Store.YES, Field.Index.NOT_ANALYZED));
/*     */   }
/*     */   
/*     */   public void removeMailboxBlobId()
/*     */   {
/* 182 */     this.document.removeFields("l.mbox_blob_id");
/*     */   }
/*     */   
/*     */   public void addSortDate(long value) {
/* 186 */     this.document.add(new Field("l.date", DateTools.timeToString(value, DateTools.Resolution.MILLISECOND), Field.Store.YES, Field.Index.NOT_ANALYZED));
/*     */   }
/*     */   
/*     */ 
/*     */   public void removeSortDate()
/*     */   {
/* 192 */     this.document.removeFields("l.date");
/*     */   }
/*     */   
/*     */   public void addContactData(String value) {
/* 196 */     this.document.add(new Field("l.contactData", value, Field.Store.NO, Field.Index.ANALYZED));
/*     */   }
/*     */   
/*     */   public void addObjects(String value) {
/* 200 */     this.document.add(new Field("has", value, Field.Store.NO, Field.Index.ANALYZED));
/*     */   }
/*     */   
/*     */   public void addVersion(int value) {
/* 204 */     this.document.add(new Field("l.version", String.valueOf(value), Field.Store.YES, Field.Index.NOT_ANALYZED));
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/index/IndexDocument.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */